#ifndef OCK_MEMORY_BRIDGE_READABLE_UTILS_H
#define OCK_MEMORY_BRIDGE_READABLE_UTILS_H
#include <iostream>
#include <iomanip>
#include "OckSafeUtils.h"
namespace ock {
namespace utils {
    
inline std::ostream &ByteToReadable(std::ostream &os, uint64_t byteCount)
{
    const double BYTE_SYSTEM = 1024.0;
    const int KEEP_DIGITS = 2;

    if (byteCount <= BYTE_SYSTEM) {
        os << byteCount << "B";
    } else if (byteCount <= (BYTE_SYSTEM * BYTE_SYSTEM)) {
        os << std::setiosflags(std::ios::fixed) << std::setprecision(KEEP_DIGITS)
           << (double) byteCount / BYTE_SYSTEM << "KB";
    } else if (byteCount <= (BYTE_SYSTEM * BYTE_SYSTEM * BYTE_SYSTEM)) {
        os << std::setiosflags(std::ios::fixed) << std::setprecision(KEEP_DIGITS)
           << (double) byteCount / (BYTE_SYSTEM * BYTE_SYSTEM) << "MB";
    } else {
        os << std::setiosflags(std::ios::fixed) << std::setprecision(KEEP_DIGITS)
           << (double) byteCount / (BYTE_SYSTEM * BYTE_SYSTEM * BYTE_SYSTEM) << "GB";
    }
    return os;
}
}
}
#endif